﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using taurus.client;

namespace test
{
    class Program
    {
        

        
        static void Main(string[] args)
        {
            ITObject validate = TObject.newInstance();
            validate.putString("user", "tt001");

            TaurusConfig config = new TaurusConfig();
            config.host = "127.0.0.1:10010";
            config.udpPort = 10020;
            config.game = "test";
            config.protocol = ConnectionProtocol.Tcp;
            TaurusClient client = new TaurusClient(config);
            client.connect();

            client.addEventListener(NetClientEvent.Connect, (evt) =>
            {
                SocketCode code = (SocketCode)evt.getParameter("code");

                if (code == SocketCode.Connect)
                {
                    ITObject _data = new TObject();
                    _data.putInt("pram", 111);
                    client.sendToUdp("t1/udp_test", _data);
                    client.send("t1/tcp_test", _data, null);
                }
                else
                {
                    Logger.info("连接失败");
                }
            });
            client.addEventListener(NetClientEvent.OnEvent, (evt) =>
             {
                 var msg = evt.getParameter("msg") as Message;
                 Logger.info(msg.useUdp ?"udp":"tcp"+ " -> " +msg.command);
             });



            while (true)
            {
                NetManager.processEvents();

                Thread.Sleep(10);

            }
        }
    }
}
